// 1.导入koa-router包
const Router = require('koa-router')

const { create, findAll, update} = require('../controller/order.controller')

// 2.实例化对象
const router = new Router({prefix: '/orders'})

// 中间件/控制器
const { auth } = require('../middleware/auth.middleware')
const { validator } = require('../middleware/order.middleware')


// 提交订单接口
router.post('/', auth, validator({
    address_id: 'int',
    goods_info: 'string',
    total: 'string'
}), create)

// 获取订单列表
router.get('/', auth, findAll) 

// 修改订单接口
router.patch('/:id', auth, validator({
    status: 'number'
}),update)
module.exports = router